{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Getting Started with JupyterHub Tutorial\n",
    "\n",
    "## Resources\n",
    "- [JupyterHub Documentation](https://jupyterhub.readthedocs.io)\n",
    "- [the PDF of PyData London 2016 slidedeck](https://github.com/minrk/jupyterhub-pydata-2016/blob/master/JupyterHub.pdf)\n",
    "- [the video on YouTube of PyData London 2016 tutorial](https://www.youtube.com/watch?v=LkgSCjyv75s)\n",
    "- [Timeline of video](./timeline.md)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Introduction\n",
    "0:00:00 Welcome and Intro\n",
    "\n",
    "0:01:00 GitHub repo that accompanies the talk\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Review of Notebook and Notebook Server\n",
    "\n",
    "0:01:44 What is the Notebook?\n",
    "\n",
    "0:03:00 What is a Notebook Server?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Overview of JupyterHub\n",
    "\n",
    "0:04:17 JupyterHub\n",
    "\n",
    "0:05:41 Login\n",
    "\n",
    "0:05:55 Spawner\n",
    "\n",
    "0:06:27 Proxy\n",
    "\n",
    "0:07:11 Redirect user\n",
    "\n",
    "0:07:17 Browser to ask hub for auth\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Installation\n",
    "\n",
    "\n",
    "0:07:56 Installation (as admin)\n",
    "\n",
    "0:10:44 Installation (this repo)\n",
    "\n",
    "0:11:18 Installation: Caveats\n",
    "\n",
    "0:12:18 conda-forge\n",
    "\n",
    "- community maintained conda packages\n",
    "- Add conda-forge to default conda sources\n",
    "\n",
    "0:13:38 Installation docker (covered later on)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### JupyterHub Defaults\n",
    "\n",
    "0:14:18 JupyterHub Defaults\n",
    "\n",
    "- Default behavior\n",
    "- Auth: PAM\n",
    "- Spawning: Local users\n",
    "- Hub run as root (alternative: sudospawner is fraught with peril)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Security and SSL\n",
    "\n",
    "0:15:12 Type jupyterhub in terminal\n",
    "\n",
    "- message returned that the hub will not start since there is no SSL provisioned\n",
    "- If you want to run without SSL, do so at your own risk.\n",
    "\n",
    "0:16:26 SSL\n",
    "\n",
    "- Use a self signed cert\n",
    "- Let's Encrypt 0:17:30"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Configuration of Hub\n",
    "\n",
    "0:18:12 Configure jupyterhub\n",
    "\n",
    "- create file\n",
    "- edit config file 0:19:12\n",
    "\n",
    "0:20:33 Connect to hub publicly\n",
    "\n",
    "- login, spawn server, redirect\n",
    "- control panel 0:21:20\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Kernels and Programming Languages\n",
    "\n",
    "0:21:52 Installing kernels for all users"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Authentication\n",
    "\n",
    "0:24:15 Using GitHub OAuth\n",
    "\n",
    "- We have simple PAM; tell server to use GitHub OAuth\n",
    "- Authorization callback URL\n",
    "- Client ID\n",
    "- Client Secret\n",
    "\n",
    "- ./env -> export the variables\n",
    "\n",
    "0:30:44 Tell Jupyter to use oauthenticator\n",
    "\n",
    "0:32:48 Sign in with GitHub\n",
    "\n",
    "0:34:20 Specifying users\n",
    "\n",
    "- PAM ok\n",
    "- GitHub probably not ok\n",
    "- user whitelist - put in a python set in config file\n",
    "- admin users - put in a python set in config file\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Custom Authenticators\n",
    "\n",
    "0:36:26 JupyterHub Custom Authenticators\n",
    "\n",
    "- PAM - form based fairly simple\n",
    "- Secure Authenticator\n",
    "- jupyterhub hashing salted functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Spawners - DockerSpawner\n",
    "\n",
    "0:42:14 Using DockerSpawner\n",
    "\n",
    "- netifaces - python convenience library\n",
    "- local GH to general GH users\n",
    "- GH - DockerSpawner and whitelist\n",
    "\n",
    "0:44:00 Initially missing piece Hub API if cookie is valid\n",
    "\n",
    "- docker0 ip address netifaces\n",
    "\n",
    "0:48:00 Lots you can do with DockerSpawner"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Custom Spawners\n",
    "\n",
    "0:51:19 Customizing JupyterHub Spawners\n",
    "\n",
    "- Start my server goes to a form\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Deployment\n",
    "\n",
    "1:07:00 JupyterHub with supervisor\n",
    "\n",
    "1:09:00 Reference deployments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Wrap Up\n",
    "\n",
    "1:11:00 Q & A\n",
    "\n",
    "1:13:00 Simula deployment with persistence in Hub\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
